'use strict';

module.exports = app => {
    const { STRING, INTEGER } = app.Sequelize;
    // actionId, contractProviderId_actionSelector, userAddr, arg, amount, userTimeStamp, sign, timeStamp, sign, timeStamp
    const Account = app.model.define('accounts', {
        id: { type: INTEGER, primaryKey: true, autoIncrement: true },
        accountAddress: { type: STRING, allowNull: false },
        userAddress:  { type: STRING, allowNull: false },
        balance:  { type: INTEGER, allowNull: false },// BIGINT
        freezeBalance:  { type: INTEGER, allowNull: false } // BIGINT
           
    });
    Account.associate = function() {
        // 
        app.model.Account.hasMany(app.model.Action, { foreignKey: 'accountId',targetKey:'id'});
    }
    return Account;
};